package com.caipiao.crawler.pailie;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.caipiao.constant.CrawlerConstants;
import com.caipiao.crawler.model.LotteryNumber;
import com.caipiao.crawler.page.BasePageProcessor;
import us.codecraft.webmagic.Page;

/**
 * Created by adminitrator on 2018/7/28.
 */
public class Pailie5DetailPage extends BasePageProcessor {

    @Override
    public void process(Page page) {
        String url = page.getUrl().toString();
            //处理接口数据
            processData(page);
    }

    /**
     * 更新排列5的销售额和奖金池
     * @param page
     */
    public void processData(Page page) {
        String id = page.getHtml().xpath("//div[@class='result']/table/tbody/tr/td[1]/text()").toString();
        String total_sales = page.getHtml().xpath("//div[@class='result']/table/tbody/tr/td[6]/text()").toString();
        String prize_pool = page.getHtml().xpath("//div[@class='result']/table/tbody/tr/td[7]/text()").toString();
        LotteryNumber model5 = new LotteryNumber();
        model5.setTerm(id);
        model5.setTotal_sales(total_sales);
        model5.setPrize_pool(prize_pool);
        model5.setType(3);
        page.putField("model5", model5);
    }

}
